/*
	Copyright (c) 2010 <copyright holders>
	This source code is licensed under The MIT License,
	see the file LICENSE for details.
	*/

#ifndef MENUGUI_HPP
#define MENUGUI_HPP

#include "GameGUI.hpp"
#include "Spatial.hpp"

namespace spelprog2 {
namespace gui {

class MenuGUI : public GameGUI {
    Game & game_;

    std::vector<std::string> replayPaths_;

    bool inLobby_;
    bool connectAsHost_;

    void initMenuSheet();
    void initLobbySheet();
    void initReplaySheet();
    void initConnectWindow();

    //event handlers for menu sheet
    void clickLaunchTestButton(const QuickGUI::EventArgs & ev);
    void clickLobbyButton(const QuickGUI::EventArgs & ev);
    void clickReplayButton(const QuickGUI::EventArgs & ev);
    void clickExitButton(const QuickGUI::EventArgs & ev);

    //event handlers for lobby sheet
    void clickConnectButton(const QuickGUI::EventArgs & ev);
    void clickConnectStartButton(const QuickGUI::EventArgs & ev);
    void clickConnectProceedButton(const QuickGUI::EventArgs & ev);
    void clickConnectCancelButton(const QuickGUI::EventArgs & ev);
    void enterChatMessage(const QuickGUI::EventArgs & ev);

    //event handlers for replay sheet
    void clickReplayStartButton(const QuickGUI::EventArgs & ev);
    void clickReplayCancelButton(const QuickGUI::EventArgs & ev);
    void changeReplayListSelection(const QuickGUI::EventArgs & ev);

    void showConnectWindow(bool host);
    void setLobbySideVisibility(bool visible);
    void updateLobbySide();
    void refreshReplayList();
public:
    MenuGUI(Game & game, Ogre::SceneManager & sceneMan);
    virtual ~MenuGUI();

    void registerNetListeners();
    void unregisterNetListeners();

    //! Initializes the entire GUI. Not pretty, but suitable for reqs of this project.
    void init();

    void insertChatLine(const std::string & text);
    void prepareForPlay(sim::Int seed);
};

};
};

#endif //MENUGUI_HPP